//
//  DetailViewController.m
//  植物管理
//
//  Created by liujianlong on 2022/11/23.
//

#import "DetailViewController.h"
#import "DetaillCell.h"
#import "AddViewController.h"

@interface DetailViewController ()
@property (strong, nonatomic) IBOutlet UIButton *btn;

@end

@implementation DetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
}
- (void)initUI{
    self.title = LS(@"详情");
    [self.rightBtn setImage:[UIImage imageNamed:@"删除"] forState:UIControlStateNormal];
    self.tableView.c_top.equalTo(self.view);
    self.tableView.c_left.equalTo(self.view);
    self.tableView.c_right.equalTo(self.view);
    self.tableView.c_bottom.equalTo(self.view);
    [self.tableView registerNib:[DetaillCell nib] forCellReuseIdentifier:[DetaillCell ID]];
    [self.view bringSubviewToFront:self.btn];
}
- (void)rightBtnAction{
    [InputViewController alert:@"删除后数据不可恢复！" block:^(NSString * _Nonnull string) {
        [JobTool delete:self.model complete:^(BOOL success) {
            [self backBtnAction];
        }];
    }];
}
- (IBAction)actionForBtn:(UIButton *)sender {
    AddViewController *vc = [AddViewController new];
    vc.model = self.model;
    [self push:vc :YES];
}
#pragma mark - UITableViewDataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    DetaillCell *cell = [tableView dequeueReusableCellWithIdentifier:[DetaillCell ID]];
    cell.model = self.model;
    return cell;
}
#pragma mark - UITableViewDelegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 0;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 0;
}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    return  nil;
}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    return nil;
}
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{
}

@end
